#include <stdio.h>

typedef unsigned short board_t;
typedef int bool;
#define true 1
#define false 0

static bool winning(board_t b)
{
    static const board_t masks[10] = {
        0x000F, 0x00F0, 0x0F00, 0xF000,
        0x1111, 0x2222, 0x4444, 0x8888,
        0x1248, 0x8421
    };
    int i;
    for (i = 0; i < 10; i++)
    {
        if ((b & masks[i]) == masks[i])
            return true;
    }
    return false;
}

#define BLACK   0   /* x; moves first */
#define WHITE   1   /* o; moves second */

#define TIE     0
#define WIN     1
#define LOSE    2

static board_t start_b;     /* mask of cells filled with 'x' */
static board_t start_w;     /* mask of cells filled with 'o' */
static int num_blanks;      /* number of blank cells */
static int our_color;       /* whether we are black or white */
static int our_goal;        /* do we want to win, lose, or tie */

static void read_game()
{
    int i, j;
    char t[20], s[4][20];
    scanf("%s %s %s %s %s", t, s[0], s[1], s[2], s[3]);

    num_blanks = 0;
    start_b = 0;
    start_w = 0;
    for (i = 0; i < 4; i++)
        for (j = 0; j < 4; j++)
        {
            if (s[i][j] == 'x')
                start_b |= (board_t)1 << (i*4+j);
            else if (s[i][j] == 'o')
                start_w |= (board_t)1 << (i*4+j);
            else
                ++num_blanks;
        }
    
    our_color = (num_blanks & 1);
    our_goal = (t[0] == 'W')? WIN : (t[0] == 'L')? LOSE : TIE;
}

static board_t lowest_bit_set(board_t x)
{
    return x & (-x);
}

/* Returns true if we can achieve the goal whatever our opponent plays. */
static bool solve(board_t b, board_t w, int num_blanks)
{
    board_t blanks = ~(b | w);
    int next_color = (num_blanks & 1);

    /* If there are no more places to play, check the status. */
    if (num_blanks == 0)
    {
        if (our_goal == WIN)
            return (our_color == BLACK && winning(b)) ||
                   (our_color == WHITE && winning(w));
        if (our_goal == LOSE)
            return (our_color == BLACK && winning(w)) ||
                   (our_color == WHITE && winning(b));
        return !winning(b) && !winning(w); /* tie */
    }

    /* Find out whose turn it is. */
    if (next_color == our_color)
    {
        /* It's our turn. Try play in each of the blanks. If any move achieves
         * the goal, we're done. */
        while (blanks)
        {
            board_t pos = lowest_bit_set(blanks);
            board_t bb = b, ww = w;
            if (next_color == BLACK && winning(bb |= pos) ||
                next_color == WHITE && winning(ww |= pos)) /* we win */
            {
                if (our_goal == WIN)
                    return true;
            }
            else
            {
                if (solve(bb, ww, num_blanks - 1))
                    return true;
            }
            blanks &= ~pos;
        }
        return false;
    }
    else
    {
        /* It's the opponent's turn. Try play in each of the blanks. If any 
         * move violates the goal, we fail. */
        while (blanks)
        {
            board_t pos = lowest_bit_set(blanks);
            board_t bb = b, ww = w;
            if (next_color == BLACK && winning(bb |= pos) ||
                next_color == WHITE && winning(ww |= pos)) /* we lose */
            {
                if (our_goal != LOSE)
                    return false;
            }
            else
            {
                if (!solve(bb, ww, num_blanks - 1))
                    return false;
            }
            blanks &= ~pos;
        }
        return true;
    }
}

int main()
{
    int num_cases;
    scanf("%d", &num_cases);
    while (num_cases--)
    {
        read_game();
        printf("%s\n", solve(start_b, start_w, num_blanks)? "YES" : "NO");
    }
    return 0;
}